<template>
  <div>
    <el-container>
      <el-container>
        <el-aside width="200px">
          <div>
            <el-menu default-active="1-4-1" class="el-menu-vertical-demo" @open="handleOpen"
                     @close="handleClose" :collapse="isCollapse">
              <el-submenu index="1">
                <template slot="title">
                  <i class="el-icon-location"></i>
                  <span slot="title" style="font-weight: 600">🐌蜗牛花卉</span>
                </template>
              </el-submenu>
              <el-menu-item index="2">
                <template slot="title">
                  <a @click="changesShop">商品管理</a>
                </template>
                <i class="el-icon-menu"></i>
              </el-menu-item>
              <el-menu-item index="2">
                <template slot="title">
                  <a @click="changesTypes">种类管理</a>
                </template>
                <i class="el-icon-menu"></i>
              </el-menu-item>
            </el-menu>
          </div>
        </el-aside>
        <el-main>
          <component :is="currentComponents"></component>
        </el-main>
      </el-container>
    </el-container>
    <!--    <h3>欢迎{{ shopsName }}来到商家页面</h3>-->
  </div>
</template>

<script>
import Shops  from "@/components/ShopsList.vue";
import TypesLists from '@/components/TypesList.vue'
import request from "@/utils/request";


export default {
  name: "shopsMain",
  data() {
    return {
      shopsName: '', // 存储从 cookie 中获取的用户名
      src: '', // 存储从 cookie 中获取的头像路径
      sbuinessForm: { // 定义用户表单数据
        sid: 0,
        sname: '',
        spassword: '',
        siphone: '',
        src: '',
        isUserNameAvailable: true, // 用于控制用户名是否可用
      },
      currentComponents: Shops,
    };
  },
  methods: {
    getToken(){
      request({
        method: 'post',
        url: 'http://localhost:9092/shops/getTook',
      }).then(res => {
        if (res.data.code === 200) {
          console.log(res)
          this.shopsName = res.data.data.sname
          this.src = res.data.data.src
        }else {
          this.$router.replace("/")
        }
      })
    },
    changesShop(){
      this.currentComponents = Shops;
    },
    changesTypes(){
      this.currentComponents = TypesLists;
    },
  },
  created() {
    this.getToken();
  },
};
</script>

<style scoped>
li {
  list-style: none;
}

.el-header, .el-footer {
  background-color: #B3C0D1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  height: 92vh; /*    等比例设置*/
}

.el-main {
  background-color: #E9EEF3;
  color: #333;
  text-align: center;
  line-height: 40px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 700px;
}

.el-dropdown-link {
  cursor: pointer;
  color: #409EFF;
}
.el-dropdown-link[data-v-f4f3bcb0] {
  cursor: pointer;
  color: #409EFF;
  position: relative;
  top: -25px;
}

.el-icon-arrow-down {
  font-size: 12px;
}

a {
  text-decoration: none;
}
</style>